﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DataLib.Accounts.Bus;

namespace Ewts.Storage
{
    public partial class CJOSelect : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ListItem item = new ListItem();
                item.Text = "--请选择--";
                item.Value = "";
                DataLib.BLL.Sys_Library bllLib = new DataLib.BLL.Sys_Library();

                // 处理地
                dropBelong.DataSource = bllLib.GetGraphicCity();
                dropBelong.DataTextField = "libValue";
                dropBelong.DataValueField = "libKey";
                dropBelong.DataBind();
                dropBelong.Items.Insert(0, item);

                BindData();
            }
        }

        public void BindData()
        {
            DataTable dt = new DataLib.BLL.CJOItem().GetCJOitemTable(null);
            reptCJO.DataSource = dt;
            reptCJO.DataBind();

        }

        protected void dropBelong_SelectedIndexChanged(object sender, EventArgs e)
        {
            string belong = dropBelong.SelectedValue;
            string where = "";
            if (belong == "全部")
                where = null;
            else
                where = " l.belongarea= '" + belong + "'";
            DataTable dt = new DataLib.BLL.CJOItem().GetCJOitemTable(where);
            reptCJO.DataSource = dt;
            reptCJO.DataBind();
        }

        /// <summary>
        /// 取得当前状态的中文描述
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        protected string GetStatus(string status)
        {
            string statusname = "";
            switch (status)
            {
                case "1":
                    statusname = "待派车";
                    break;
                case "2":
                    statusname = "待称重";
                    break;
                case "3":
                    statusname = "待授权";
                    break;
                case "4":
                    statusname = "待拆解";
                    break;
                case "5":
                    statusname = "拆解中";
                    break;
                case "-4":
                    statusname = "拆解申请审批中";
                    break;
                case "-9":
                    statusname = "作废";
                    break;
                default:
                    break;
            }
            return statusname;

        }
    }
}